# Contributor: Marvin Preuss <marvin@xsteadfastx.org>
# Maintainer: Marvin Preuss <marvin@xsteadfastx.org>
pkgname=dsnet
pkgver=0.7.3
_rev=c7096d13183159647b92aaed522a406c29b91798 # used for version command
pkgrel=2
pkgdesc="fast command to manage a centralised wireguard VPN"
url="https://github.com/naggie/dsnet"
arch="all"
license="MIT"
makedepends="go"
options="!check chmod-clean" # no tests available
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/naggie/dsnet/archive/refs/tags/v$pkgver.tar.gz"

export GOFLAGS="$GOFLAGS -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build \
		-ldflags "
		-X \"github.com/naggie/dsnet.GIT_COMMIT=$_rev\" \
		-X \"github.com/naggie/dsnet.VERSION=$pkgver\" \
		-X \"github.com/naggie/dsnet.BUILD_DATE=$(date)\" \
		" \
		-o dsnet \
		./cmd/root.go
}

package() {
	install -Dm755 dsnet -t "$pkgdir"/usr/bin/

	install -Dm644 CONFIG.md README.md \
		-t "$pkgdir"/usr/share/doc/$pkgname/

	install -Dm644 LICENSE.md \
		-t "$pkgdir"/usr/share/licenses/$pkgname/
}

sha512sums="
052967576f2ac8ee9c937a6fb13f796e6ae24f46c1d4e94ffa6212cb7e4ec2de60717dcff0224698d7250dbdb585512620a856f97785fb8795a13b3066295076  dsnet-0.7.3.tar.gz
"
